package ke02.am.calculating;

public class Factorial implements Calculator<Integer, Long> {

	@Override
	public Long calculate(Integer n) {
		return fac(n);
	}

	private static Long fac(int n) {
		if (n < 1) {
			throw new IllegalArgumentException(
					"Faculty of numbers < 1 not defined");
		}
		if (n < 3) {
			return (long) n;
		} else {
			return n * fac(n - 1);
		}
	}

}